package com.swanclouds.redfish.systems.domain;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.swanclouds.model.systems.VolumeInitType;

/**
 * @author 张立强
 *
 */
public class VolumeInitTypeConcrete implements VolumeInitType {

    @JsonProperty("Type")
    private InitType type;
    /**
     * 初始化的方式
     * @see VolumeInitType.InitType
     * @return type
     */
    @Override
    public String getType() {
        return type.name();
    }

    public static VolumeInitTypeConcrete builder() {
        return new VolumeInitTypeConcrete();
    }

    public VolumeInitTypeConcrete type(InitType type) {
        this.type = type;
        return this;
    }

    @Override
    public String toString() {
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            return objectMapper.writeValueAsString(this);
        } catch (JsonProcessingException e) {
        }
        return "VolumeInitTypeConcrete {" +
                "type=" + type +
                '}';
    }
}
